package com.hnxxxy.common.WebSocket;

import com.hnxxxy.common.WebSocket.model.UserResponse;
import com.hnxxxy.common.WebSocket.model.WebSocketUser;
import com.hnxxxy.common.annotation.LogAnno;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;

@Controller
@Slf4j
public class WebSocketUserController {
    //携带的用户ID可以直接拿到给MessageMapping注解的函数注入
    @MessageMapping("/user")

    //SendTo注解指明发送目标
    @SendTo("/topic/user")
    @LogAnno(description = "SendTo注解指明发送websocket信息")
    public UserResponse getUser(WebSocketUser user) {
        log.info("-->请求方法：SendTo注解指明发送websocket信息");
        return new UserResponse("您有新的审核信息");
    }
}
